<html>
<head>

		<?php
    INCLUDE 'header.php';
		
	$complemento = "";
	if(isset($_POST["filtro"]))
	{
	$filtro = $_POST["filtro"];
	$complemento = " where nome ILIKE '%$filtro%'";
	}		


	$sql = "select * from animal".$complemento;	
	//monto a consulta
	 //$sql = "select * from animal";

	
	 //executo no banco, retornando os registros da tabela
	 $lista = pg_query($sql);
	 
	
	 ?>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
		<title>Sistema de controle de fazendas</title>
		  </head>
		  <body>
		<div class="pull-right"> 
		<div class="btn" title="novo animal"><i class="icon-edit"></i><a></a></div>
		<div class="btn" title="sair"><i class="icon-share-alt"></i><a></a></div>
		</div>
		<legend><i class="icon-search"></i>Pesquisar animais</legend>
	  
		<form class="form-search" action="listarAnimais.php" method="post">
	
		<input class="input-medium search-query" placeholder="faça sua busca" type="text" name="filtro"></input>
		<button class="btn btn-warning" type="submit" value="pesquisar">buscar</button>
		</form>
	
		
	<table class="table table-hover">
    <caption></caption>
    <thead>
	 <tbody>
    <tr class="info">
    <th>Id</th>
    <th>Nome</th>
	<th>Raca</th>

    </tr>
    </thead>
   <?php
   while($animal = pg_fetch_assoc($lista))
   {
   
   ?>
   
    <tr>
    <td><?php echo $animal ["id"]?></td>
    <td><?php echo $animal ["nome"]?></td>
	<td><?php echo $animal ["raca"]?></td>
     
	<td><a title="excluir" href="vacina-excluir-ok.php?id=<?php echo $animal["id"]?>"><i class="icon-trash"></i></a>
	<a title="alterar" href="cadastroAnimal.php?id=<?php echo $animal["id"]?>"><i class="icon-pencil"></i></a></td> </tr>
	
	<?php 
	}
    ?>

    </tbody>
    </table>
    </table>
	</body>
</html>
<!--youtube.com/programatcheif-->